// user controller
import { Controller, Get, Res } from "@nestjs/common";
import { UserService } from "../services/user";
import { Response } from "express";

@Controller("user")
export class UserController {
  constructor(private readonly userService: UserService) {}
  @Get("/list")
  async getUsers(@Res() res: Response) {
    try {
      const [users, count] = await this.userService.queryList();
      return res.status(200).json({
        status: 200,
        message: "Users retrieved successfully",
        data: { users, count },
      });
    } catch (error) {
      console.error("Error in getUsers:", error); // 添加详细的错误日志
      return res.status(500).json({
        status: 500,
        message: "Internal server error",
      });
    }
  }
}
